home *** CD-ROM | disk | FTP | other *** search
/ Garbo / Garbo.cdr / mac / hypercrd / hc2_x / tcprogud.sit / TC Prog Guide / card_25356.txt < prev    next >
Text File  |  1991-02-27  |  1KB  |  25 lines

  1. -- card: 25356 from stack: in
  2. -- bmap block id: 0
  3. -- flags: 0000
  4. -- background id: 4755
  5. -- name: 
  6.  
  7.  
  8. -- part contents for background part 4
  9. ----- text -----
  10. CHARACTER STRINGS
  11.  
  12. A character string constant is a sequence of characters enclosed in double quotes, and represents an array of character values.  The last element of the array is the non-printable "null" character: '\0', supplied automatically in string constants.  A string constant is treated by C syntactically as the name of a character array, which itself is a pointer to the zeroth element of the array.  Thus the following assigns the address of the zeroth element of the string "Hello, world!" to c_ptr:
  13.  
  14.     char    *c_ptr;
  15.     c_ptr = "Hello, world!";
  16.  
  17. Now, the elements of the string may be accessed using either array indexing:  c_ptr[4], or pointer arithmetic:  *(c_ptr+4).  It is important to note that the string defined above is a constant value and ANSI C disallows assignments which change it:
  18.  
  19.     c_ptr[4] = 'x';        /*  disallowed in this case, since "Hello, world!" is a constant  */
  20.                                    /*  in truth, Think C 4.0 still allows this  */
  21.  
  22.  
  23. -- part contents for background part 7
  24. ----- text -----
  25. 63